<?php use_helper('LetsManager','Date') ?>

<?php if ($sf_user->hasFlash('notice')): ?>
  <p class="notice"><?php echo $sf_user->getFlash('notice') ?></p>
<?php endif ?>

<h2><?php echo $titlePending ?></h2>

<table style="width: 95%" class="datalist">
  <thead>
    <tr>
      <th width="5%">N°</th>
      <th width="20%">Partenaire</th>
      <th width="10%">Catégorie</th>
      <th>Service</th>
      <th width="15%">Montant</th>
      <th width="15%">Créé le</th>
    </tr>
  </thead>
  <tbody>
  <?php foreach ($exchangesPending as $exchange): ?>
    <tr>
      <td><?php echo $exchange->getId() ?></td>
      <td><?php echo lets_format_member($exchange->getPartnerMember($sf_user->getUserId())) ?></td>
      <td><?php echo $exchange->getCategory()->getName() ?></td>
      <td><?php echo $exchange->getName() ?></td>
      <td><?php echo $exchange->getAmountWithSign($sf_user->getUserId()) ?></td>
      <td><?php echo format_date($exchange->getCreatedAt())?></td>
    </tr>
    <?php endforeach ?>
    <?php if(count($exchangesPending)==0): ?>
    <tr>
      <td colspan="6">Aucune échange en attente</td>
    </tr>
    <?php endif ?>
  </tbody>
</table>

<h2><?php echo $titleExchanges ?></h2>

<table class="datalist">
  <thead>
    <tr>
      <th width="5%">N°</th>
      <th width="8%">Date</th>
      <th width="15%">Crediteur</th>
      <th width="15%">Debiteur</th>
      <th>Catégorie</th>
      <th>Description</th>
      <th width="5%">Montant</th>
      <th width="5%">Etat</th>
    </tr>
  </thead>
  <tbody>
  <?php foreach ($echangesPager as $echange): ?>
    <tr id="exchange_<?php echo $echange->getId() ?>">
      <td><?php echo $echange->getId() ?></td>
      <td><?php echo format_date($echange->getCreatedAt()) ?></td>
      <td><?php echo lets_format_member($echange->getCreditorUser()) ?></td>
      <td><?php echo lets_format_member($echange->getDebitorUser()) ?></td>
      <td><?php echo $echange->getCategory()->getName() ?></td>
      <td><?php echo $echange->getName() ?></td>
      <td><?php echo $echange->getAmount() ?></td>
      <td><?php echo $echange->getStateValidationString() ?></td>
    </tr>
  <?php endforeach ?>
  </tbody>
</table>
<?php include_partial('global/pager', array('pager' => $echangesPager, 'route' => '@lets_exchangesByUser_list', 'params' => array())) ?>